<template>
    <div>
        <Header />
        <Covid19Info :covid19Info="covid19Info"/>
        <CaseNum :caseNumData="caseNumData" />
        <Map />
        <MySwiper />
        <SpringTravel />
    </div>
</template>

<script>
import api from "../api";
import Header from '../components/Header'
import Covid19Info from '../components/Covid19Info'
import CaseNum from '../components/CaseNum'
import Map from '../components/Map'
import MySwiper from '../components/MySwiper'
import SpringTravel from '../components/SpringTravel'

export default {
    name: 'Home',

    data() {
        return {
            // 疫情信息：covid19Info
            covid19Info: {
                note1: '病毒: SARS-CoV-2, 其导致疾病命名 COVID-19',
                note2: '传染源: 新冠肺炎的患者。无症状感染者也可能成为传染源。',
                note3: '传播途径: 经呼吸道飞沫、接触传播是主要的传播途径。气溶胶传播和消化道等传播途径尚待明确',
                remark1: '易感人群: 人群普遍易感。老年人及有基础疾病者感染病情较重。儿童及婴幼儿也有发病',
                remark2: '潜伏期: 一般为 3~7 天, 最长不超过14天, 潜伏期内可能存在传染性, 其中无症状病例传染性非常罕见',
                remark3: '宿主: 野生动物, 可能为中华菊头蝠',
            },
            caseNumData: {
                modifyTime: "", // 更新时间
                currentConfirmedCount: "", // 现存确诊人数
                confirmedCount: "", // 累计确诊人数
                suspectedCount: "", // 累计境外输入人数
                curedCount: "", // 累计治愈人数
                deadCount: "", // 	累计死亡人数
                seriousCount: "", // 现存无症状人数
                suspectedIncr: "", // 新增境外输入人数
                currentConfirmedIncr: "", // 相比昨天现存确诊人数
                confirmedIncr: "", // 相比昨天累计确诊人数
                curedIncr: "", // 相比昨天新增治愈人数
                deadIncr: "", // 相比昨天新增死亡人数
                seriousIncr: "", //相比昨天现存无症状人数
            },
        }
    },
    components: {
        Header,
        Covid19Info,
        CaseNum,
        Map,
        MySwiper,
        SpringTravel
    },
    mounted() {
        api.getNcov({
            key: '5204662667db1dc1ee2a28bbf7207d7f',
        }).then(res => {
            // console.log(res)
            if(res.status === 200) {
                let desc = res.data.newslist[0].desc
                // 疫情信息
                // this.covid19Info.note1 = desc.note1;
                // this.covid19Info.note2 = desc.note2;
                // this.covid19Info.note3 = desc.note3;
                // this.covid19Info.remark1 = desc.remark1;
                // this.covid19Info.remark2 = desc.remark2;
                // this.covid19Info.remark3 = desc.remark3;

                // 疫情病例
                this.caseNumData.modifyTime = desc.modifyTime;
                this.caseNumData.currentConfirmedCount = desc.currentConfirmedCount;
                this.caseNumData.confirmedCount = desc.confirmedCount;
                this.caseNumData.suspectedCount = desc.suspectedCount;
                this.caseNumData.curedCount = desc.curedCount;
                this.caseNumData.deadCount = desc.deadCount;
                this.caseNumData.seriousCount = desc.seriousCount;
                this.caseNumData.suspectedIncr = desc.suspectedIncr;
                this.caseNumData.currentConfirmedIncr = desc.currentConfirmedIncr;
                this.caseNumData.confirmedIncr = desc.confirmedIncr;
                this.caseNumData.curedIncr = desc.curedIncr;
                this.caseNumData.deadIncr = desc.deadIncr;
                this.caseNumData.seriousIncr = desc.seriousIncr;
            }
        }).catch((error) => {
            console.log(error)
        })
    }
}
</script>